from problem_generator import ProblemGenerator
from multi_robot_problem import MultiRobotState
import re
#
#height, width = 10,10
#minRobs, maxRobs = 3,5
#difficulty = ProblemGenerator.HARD
#minPiles, maxPiles, minObs, maxObs = 3, 5, 3, 7 
#minWallLength, maxWallLength = 6,8
#
#robots = ((1,1),)
#obstacles = frozenset([(2,2),(2,3),(2,4),(3,2),(3,4),(4,2),(4,3),(4,4)])
#piles = frozenset([(3,3)])
#
#
#pGen = ProblemGenerator(height, width, minRobs, maxRobs, difficulty,
#    minPiles, maxPiles, minObs, maxObs, minWallLength, maxWallLength)
#problem = pGen.trollProblem()
#problem = MultiRobotState(10,10, robots, piles, obstacles)
#print problem
baseFileName = "output_astar_pile"
fileToParse = "C:\\Users\\bob\\Documents\\Python\\hw1\\src\\results\MED_"+baseFileName+".txt"
fileToWrite10 = "C:\\Users\\bob\\Desktop\\ai\\med\\"+baseFileName+"_10_med.txt"
fileToWrite20 = "C:\\Users\\bob\\Desktop\\ai\\med\\"+baseFileName+"_20_med.txt"
fileToWrite30 = "C:\\Users\\bob\\Desktop\\ai\\med\\"+baseFileName+"_30_med.txt"
FILE = open(fileToParse,"r")
line = '\n'
while(line != ''):
    line = FILE.readline()
    prefix = re.match("(problem number) ([0-9]+)",line)
    if not prefix is None:
        line10 = FILE.readline()
        f10 = open(fileToWrite10,"a")
        f10.write(prefix.group(2)+"\t"+line10)
        f10.close()
        
        line20 = FILE.readline()
        f20 = open(fileToWrite20,"a")
        f20.write(prefix.group(2)+"\t"+line20)
        f20.close()
        
        line30 = FILE.readline()
        f30 = open(fileToWrite30,"a")
        f30.write(prefix.group(2)+"\t"+line30)
        f30.close()
        